<template>
	<view class="app">
		<view class="header">
			<view class="zdyzhif">
				<image class="jqtub" src="../../static/jiner.png"></image>
				<input class="shuruj" type="number" v-model="czjine" placeholder="输入充值金额"/>
			</view>
			<view class="kzjcds">
				<view>快捷充值</view>
				<view class="kexcz">
					<view v-for="(item,index) in czmz" :key="index" :class="dqje==item?'dqxz':'weixz'" @click="xuanzjr(item)">{{item}}</view>
				</view>
			</view>
		</view>
		<view class="pay-type">
			<view class="pay-item" v-for="(item,index) in payList" :key="index" @click="changePayType(index)">
				<view class="pay-item-left">
					<image mode="widthFix" class='pay-icon' :src="'../../static/'+item.img"></image>
					{{item.name}}
				</view>
				<image v-if="payType==index" class="check-icon" src="../../static/checked.png"></image>
				<image v-else class="check-icon" src="../../static/no-check.png"></image>
			</view>
		</view>
		<view class="footer">
			<view class="zfann" @click="zhifwanc">确认充值</view>
		</view>
	</view>
</template>
<script>
export default{
	data(){
		return {
			czjine:'',
			dqje:10,
			czmz:[10,20,50,100,200,500],
			payList:[
				{name:"微信支付",img:"wepay.png"},
				{name:"银联支付",img:"pay-1.png"},
				{name:"线下支付",img:"pay-2.png"},
				{name:"支付宝支付",img:"alipay.png"},
			],
			payType:0
		}
	},
	methods:{
		changePayType(type){
			this.payType=type;
		},
		zhifwanc(){
			uni.request({
				url: getApp().globalData.url + '/client/AddYuer',
				data: {
					id: uni.getStorageSync('user_key').id,
					money: this.dqje,
					zffs: this.payList[this.payType].name,
				},
				method: "POST",
				header: {
					"Content-Type": "application/x-www-form-urlencoded"
				},
				success: (res) => {
					// console.log(res);
					if(res.data.code == 200) {
						uni.navigateTo({
							url:'../payResult/payResult'
						})
					} else {
						uni.showToast({
							title: "充值失败",
							icon: "none"
						})
					}
			
				}
			})
		},
		xuanzjr(jiner){
			this.dqje = jiner;
			this.czjine = jiner;
		}
	}
}
</script>
<style scoped lang="scss">
	.header {
		background-color: #f4f4f4;
		position: relative;
		// text-align: center;
		padding-top: 50rpx;
		padding-bottom: 50rpx;
		.zdyzhif{
			width: 610rpx;
			margin: 0 50rpx;
			padding:20rpx 20rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			// background: #cccccc;
			border-radius: 10rpx;
			border: solid 1rpx #b1b1b1;
			.jqtub{
				width: 40rpx;
				height: 40rpx;
			}
			.shuruj{
				width: 490rpx;
				padding: 5rpx 30rpx;
				// background: #0000FF;
			}
		}
		.kzjcds{
			width: 610rpx;
			margin: 0 50rpx;
			padding:20rpx 20rpx;
			font-size: 28rpx;
			color: #333333;
			.kexcz{
				display: flex;
				align-items: center;
				flex-wrap: wrap;
				padding-top: 20rpx;
				.dqxz{
					width: 130rpx;
					height: 60rpx;
					background: #ff007f;
					display: flex;
					align-items: center;
					justify-content: center;
					font-weight: bold;
					color: #ffffff;
					border-radius: 10rpx;
					margin: 0 22rpx 20rpx 0;
				}
				.weixz{
					width: 130rpx;
					height: 60rpx;
					background: #cacaca;
					display: flex;
					align-items: center;
					justify-content: center;
					font-weight: bold;
					color: #6b6b6b;
					border-radius: 10rpx;
					margin: 0 22rpx 20rpx 0;
				}
			}
		}
		

		.header-text-1 {
			color: #969696;
			font-size: 26rpx;
			margin-bottom: 19rpx;
		}

		.header-text-2 {
			color: #969696;
			font-size: 26rpx;

			text {
				color: #ff0000;
				padding: 0 10rpx;
			}
		}
	}
	.pay-item{
		height: 102rpx;
		padding: 0 32rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		.pay-item-left{
			display: flex;
			align-items: center;
			font-size: 26rpx;
			color: #222222;
			.pay-icon{
				width: 42rpx;
				margin-right: 20rpx;
			}
		}
		.check-icon{
			width: 32rpx;
			height: 32rpx;
		}
	}
	.footer{
		display: flex;
		position: fixed;
		align-items: center;
		justify-content: center;
		bottom: 30rpx;
		width: 100%;
		.zfann{
			width: 670rpx;
			height: 80rpx;
			background: #ff007f;
			display:flex;
			justify-content: center;
			align-items: center;
			color: #ffffff;
			border-radius: 40rpx;
		}
	}
</style>
